﻿@model AgentSettingsModel
@using Urs.Core.Domain.Orders
@using Urs.Core.Domain.Customers
@using Urs.Data.Domain.Agents
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">分销设置</div>
                <div class="layui-card-body">
                    <div class="layui-form" wid200 lay-filter="">
                        <div class="layui-form-item">
                            <nop-label asp-for="Method" />
                            <div class="layui-input-inline">
                                <nop-select asp-for="Method" asp-items="@(((AgentBonusMethod)Model.Method).ToSelectList())" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <nop-label asp-for="BonusForHandout_Awarded" />
                            <div class="layui-input-inline">
                                <nop-select asp-for="BonusForHandout_Awarded" asp-items="@(((OrderStatus)Model.BonusForHandout_Awarded).ToSelectList())" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <nop-label asp-for="BonusForHandout_Canceled" />
                            <div class="layui-input-inline">
                                <nop-select asp-for="BonusForHandout_Canceled" asp-items="@(((OrderStatus)Model.BonusForHandout_Awarded).ToSelectList())" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">一级分销启用</label>
                            <div class="layui-input-inline">
                                <nop-editor asp-for="Rate" />
                            </div>
                            <div class="layui-form-mid layui-word-aux">
                                百分比（%）
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">二级分销启用</label>
                            <div class="layui-input-inline">
                                <nop-bool asp-for="ParentAgentEnabled" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">二级分销佣金</label>
                            <div class="layui-input-inline">
                                <nop-editor asp-for="ParentRate" />
                            </div>
                            <div class="layui-form-mid layui-word-aux">
                                百分比（%）
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="btn_save">确认保存</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'set'], function () {
        var $ = layui.$
            , form = layui.form;
        form.on('submit(btn_save)', function (obj) {
          var field = obj.field; //获取提交的字段
            //layer.msg(JSON.stringify(obj.field));
            //提交 Ajax 成功后，关闭当前弹层并重载表格
            $.post('@Url.Action("AgentSet")', field, function (rep) {
                if (rep.success == 1) {
                    layer.msg('保存成功');
                    window.location.reload();
                } else {
                    layer.msg(rep.msg);
                }
            });
            return false;
    });
        $('.layui-btn.layuiadmin-btn-tags').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });

</script>
